;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TODO using summing instead of finnaly?
(defun p48 (n)
  (mod
	(loop for i from 1 to n
		  and result = 0 then (+ result (expt i i))
		  finally (return result))
	(expt 10 10)))

(defun p48-2 (n)
  (mod
    (reduce
     '+
     (mapcar
       (lambda (x) (expt x x))
       (range 1 n)))
    (expt 10 10)))

(defun range (start end)
  (loop for i from start to end collect i)) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(format t "~a~%" (time (p48 1000)))
(format t "~a~%" (time (p48-2 1000)))
